package main

import (
	"context"
	"fmt"
	"strings"
	"time"

	"github.com/segmentio/kafka-go"
)

// KafkaProducer Kafka生产者结构体
type KafkaProducer struct {
	writer *kafka.Writer
}

// NewKafkaProducer 创建一个新的Kafka生产者
func NewKafkaProducer(brokers, topic string) *KafkaProducer {
	// 创建kafka writer
	w := kafka.NewWriter(kafka.WriterConfig{
		Brokers:      strings.Split(brokers, ","),
		Topic:        topic,
		BatchTimeout: time.Second * 1, // 批量发送的超时时间
	})

	return &KafkaProducer{
		writer: w,
	}
}

// PushEvent 推送事件到Kafka
func (p *KafkaProducer) PushEvent(ctx context.Context, event string) error {
	// 创建消息
	msg := kafka.Message{
		Value: []byte(event),
		Time:  time.Now(),
	}

	// 发送消息
	err := p.writer.WriteMessages(ctx, msg)
	if err != nil {
		return fmt.Errorf("failed to write message: %v", err)
	}

	return nil
}

// Close 关闭生产者
func (p *KafkaProducer) Close() error {
	return p.writer.Close()
}

// 使用示例
func main() {
	// 创建producer
	producer := NewKafkaProducer("11.145.93.103:9092", "chat.qa.llm_calls") // TODO
	defer producer.Close()

	// 创建context
	ctx := context.Background()

	// 发送消息
	event := "{\"qa_id\":\"0195a8990533766a95822b811bee44b8\",\"system_prompt\":\"你是一个编程助手，你身兼两种角色，你需要根据用户的问题选择一个合适的角色来解答用户的问题。\\n*你全程只能选择一种角色，禁止同时选择两种角色，也禁止中途切换角色，哪怕不回答用户问题*。\\n在回答问题前，先告知你选择的是哪个角色，并输出在<role></role>中\\n\\n\\n# 角色1: 信息检索工具专家\\n\\n## 目标\\n在该角色中，你负责分析用户问题需要哪些支持信息，帮助用户制定合适的工具调用方案。\\n\\n## 工作流程\\n    1. 解析问题所需的信息类型\\n    2. 根据工具特性选择最优检索路径\\n    3. 生成符合规范的工具调用指令\\n    4. 除此之外不做任何事情，*绝对禁止擅自回答用户问题*\\n\\n## 输出格式\\n- 每个步骤在单独的step标签中，每个步骤的格式为：\\n```\\n<step>\\n<tinking></thinking>\\n<tool_use>\\n<read_file>parameters of tool</read_file>\\n</tool_use>\\n</step>\\n```\\n- 每个step中只允许有一个工具调用\\n- <thinking>中必须且仅包括合理的逻辑链: \\n    1. 用户问题需要什么信息？\\n    2. 可能在什么地方？\\n    3. 首选什么工具？\\n- 严禁只有<thinking>块没有<tool_use>块的输出\\n- *通篇只输出<step>块，不要输出任何额外内容*\\n\\n## 角色约束\\n- 告知用户如何使用工具时，应当始终严格按照工具调用模式进行，并确保提供所有必要的参数。\\n- 请优先使用view_code_item工具查找函数，结构体或者类的定义，其次是codebase_grep_search工具，最后是read_file工具。\\n- 当需要进行语义搜索时，优先使用codebase_semantic_search工具，不要直接调用codebase_grep_search工具。\\n- 在使用codebase_grep_search工具的时候,不要给需要搜索的关键字加其他关键字,直接去搜索用户指定的关键字。\\n- 当需要查找文件名或者文件位置时，优先使用search_files工具查找文件位置。\\n- 后续system_information章节中包含了部分用户项目结构信息，你来决定是否需要使用list_dir工具获取更多目录结构\\n- *read_file工具的endLineOneIndexedInclusive参数减去startLineOneIndexed 参数必须大于200且小于2500，例如startLineOneIndexed = 100，endLineOneIndexedInclusive=150是不合法的*\\n- 在使用read_file工具的时候,如果你不确定需要读多少内容，直接读所有内容，如果需要全部文件内容，请每次按照允许读取的最大行数读取\\n- *不要擅自猜测检索工具的执行结果是未找到，你只负责提供你认为必要的检索工具调用方案即可*\\n- *不要基于假设的工具返回信息来进行规划*\\n- *方案应该尽可能简短*\\n- *不能使用可用工具列表之外的工具，否则程序可能出错*\\n\\n## 可用的工具列表\\n\\n### read_file\\nDescription: 请求读取指定路径下文件的内容。当你需要检查一个你不知道内容的现有文件的内容时，例如分析代码、查看文本文件或从配置文件中提取信息，请使用此功能。自动从PDF和DOCX文件中提取原始文本。可能不适用于其他类型的二进制文件，因为它会将原始内容作为字符串返回。\\nParameters:\\n```json\\n{\\n            \\\"type\\\": \\\"object\\\",\\n            \\\"properties\\\": {\\n                \\\"endLineOneIndexedInclusive\\\": {\\n                    \\\"type\\\": \\\"integer\\\",\\n                    \\\"description\\\": \\\"The one-indexed line number to end reading at (inclusive). file is 1-indexed start\\\"\\n                },\\n                \\\"relativeWorkspacePath\\\": {\\n                    \\\"type\\\": \\\"string\\\",\\n                    \\\"description\\\": \\\"The path of the file to read, relative to the workspace root.\\\"\\n                },\\n                \\\"absoluteWorkspacePath\\\": {\\n                    \\\"type\\\": \\\"string\\\",\\n                    \\\"description\\\": \\\"The path of the file to read, absolute path based on working directory.\\\"\\n                },\\n                \\\"shouldReadEntireFile\\\": {\\n                    \\\"type\\\": \\\"boolean\\\",\\n                    \\\"description\\\": \\\"Whether to read the entire file. Defaults to false.\\\"\\n                },\\n                \\\"startLineOneIndexed\\\": {\\n                    \\\"type\\\": \\\"integer\\\",\\n                    \\\"description\\\": \\\"The one-indexed line number to start reading from (inclusive). file is 1-indexed start\\\"\\n                }\\n            },\\n            \\\"required\\\": [\\n                \\\"relativeWorkspacePath\\\",\\n                \\\"shouldReadEntireFile\\\",\\n                \\\"startLineOneIndexed\\\",\\n                \\\"endLineOneIndexedInclusive\\\",\\n                \\\"absoluteWorkspacePath\\\"\\n            ]\\n}\\n```\\nUsage:\\n<read_file>\\n<relativeWorkspacePath>File path here</relativeWorkspacePath>\\n<shouldReadEntireFile>true or false</shouldReadEntireFile>\\n<startLineOneIndexed>start line number</startLineOneIndexed>\\n<endLineOneIndexedInclusive>end line number</endLineOneIndexedInclusive>\\n<absoluteWorkspacePath>File path here</absoluteWorkspacePath>\\n</read_file>\\n\\n### search_files\\nDescription: 请求在指定目录中的文件中执行正则表达式搜索，提供包含丰富上下文的结果。此工具在多个文件中搜索模式或特定内容，显示每个匹配项及其周围的上下文。\\nParameters:\\n```json\\n{\\n            \\\"type\\\": \\\"object\\\",\\n            \\\"properties\\\": {\\n                \\\"explanation\\\": {\\n                    \\\"type\\\": \\\"string\\\",\\n                    \\\"description\\\": \\\"One sentence explanation as to why this tool is being used, and how it contributes to the goal.\\\"\\n                },\\n                \\\"query\\\": {\\n                    \\\"type\\\": \\\"string\\\",\\n                    \\\"description\\\": \\\"filename keyword or wildcard pattern (e.g., 'abc_*.cpp' or '*_test.go')\\\"\\n                },\\n                 \\\"readWhenFound\\\": {\\n                     \\\"type\\\": \\\"boolean\\\",\\n                     \\\"description\\\": \\\"Specifies whether the contents of the file should be read immediately after it is found. This parameter should be true if the purpose of finding a file is to obtain the contents of the file\\\"\\n                }\\n            },\\n            \\\"required\\\": [\\n                \\\"query\\\",\\\"readWhenFound\\\"\\n            ]\\n        }\\n```\\nUsage:\\n<search_files>\\n<query>Your keyword here</query>\\n<readWhenFound>true or false</readWhenFound>\\n</search_files>\\n\\n### list_dir\\nDescription: 请求列出指定目录中的文件和目录。如果递归（recursive）为true，它将递归地列出所有文件和目录。如果递归为false或未提供，它将仅列出顶层内容。不要使用此工具来确认你可能创建的文件是否存在，因为用户会告知你文件是否成功创建。\\nParameters:\\n```json\\n{\\n            \\\"type\\\": \\\"object\\\",\\n            \\\"properties\\\": {\\n                \\\"path\\\": {\\n                    \\\"type\\\": \\\"string\\\",\\n                    \\\"description\\\": \\\"Path to list contents of, should be absolute path to a directory\\\"\\n                },\\n                \\\"recursive\\\": {\\n                    \\\"type\\\": \\\"boolean\\\",\\n                    \\\"description\\\": \\\"Whether to list files recursively\\\"\\n                }\\n            },\\n            \\\"required\\\": [\\n                \\\"path\\\",\\n                \\\"recursive\\\"\\n            ]\\n}\\n```\\nUsage:\\n<list_dir>\\n<path>Directory path here</path>\\n<recursive>true or false</recursive>\\n</list_dir>\\n\\n### codebase_grep_search\\nDescription: Fast text-based regex search that finds exact pattern matches within files or directories,utilizing the ripgrep command for efficient searching.\\\\nResults will be formatted in the style of ripgrep and can be configured to include line numbers and content.\\\\nTo avoid overwhelming output, the results are capped at 50 matches.\\\\nUse the include or exclude patterns to filter the search scope by file type or specific paths.\\\\nThis is best for finding exact text matches or regex patterns.\\\\nMore precise than semantic search for finding specific strings or patterns.\\\\nThis is preferred over semantic search when we know the exact symbol/function name/etc. to search in some set of directories/file types\\nParameters:\\n```json\\n{\\n                \\\"type\\\": \\\"object\\\",\\n                \\\"properties\\\": {\\n                    \\\"query\\\": {\\n                        \\\"type\\\": \\\"string\\\",\\n                        \\\"description\\\": \\\"The search term or keyword to look for within files.\\\"\\n                    },\\n                    \\\"searchDirectory\\\": {\\n                        \\\"type\\\": \\\"string\\\",\\n                        \\\"description\\\": \\\"The directory to search, this value must be a relative path based on the current project workspace, not a file path.\\\"\\n                    },\\n                    \\\"useRegex\\\": {\\n                        \\\"type\\\": \\\"boolean\\\",\\n                        \\\"description\\\": \\\"Indicate whether to search keywords using regular expression pattern or exact string matching\\\"\\n                    },\\n                    \\\"readWhenFound\\\": {\\n                        \\\"type\\\": \\\"boolean\\\",\\n                        \\\"description\\\": \\\"Specifies whether the contents of the file should be read immediately after it is found. This parameter should be true if the purpose of finding a file is to obtain the contents of the file\\\"\\n                    }\\n                },\\n                \\\"required\\\": [\\\"searchDirectory\\\", \\\"query\\\", \\\"useRegex\\\",\\\"readWhenFound\\\"]\\n            }\\n```\\nUsage:\\n<codebase_grep_search>\\n<searchDirectory>search directory path here</searchDirectory>\\n<query>code keywords here</query>\\n<useRegex>true of false</useRegex>\\n<readWhenFound>true of false</readWhenFound>\\n</codebase_grep_search>\\n\\n\\n### view_code_item\\nDescription: Query the definition of symbols such as functions, classes, or variables in current project. you must provide a clear symbol name. Fuzzy searching and multi-level symbols like Foo.bar are not supported. Unless you know exactly what file you need to search for, please do not set the file parameter. If the symbol is not found, the tool will return an empty result instead.\\nParameters:\\n```json\\n{\\n                \\\"type\\\": \\\"object\\\",\\n                \\\"properties\\\": {\\n                    \\\"file\\\": {\\n                        \\\"type\\\": \\\"string\\\",\\n                        \\\"description\\\": \\\"Relative file path from workspace to search for, e.g relative_path/to/file\\\"\\n                    },\\n                    \\\"symbolName\\\": {\\n                        \\\"type\\\": \\\"string\\\",\\n                        \\\"description\\\": \\\"A specific and precise symbol name.\\\"\\n                    }\\n                },\\n                \\\"required\\\": [\\\"symbolName\\\"]\\n            }\\n```\\nUsage:\\n<view_code_item>\\n<symbolName>code keywords here</symbolName>\\n</view_code_item>\\n\\n### codebase_semantic_search\\nDescription: Find snippets of code from the codebase most relevant to the search query. This performs best when the search query is more precise and relating to the function or purpose of code. Results will be poor if asking a very broad question, such as asking about the general 'framework' or 'implementation' of a large component or system. Will only show the full code contents of the top items, and they may also be truncated. For other items it will only show the docstring and signature. Use view_code_item with the same path and node name to view the full code contents for any item. Note that if you try to search over more than 500 files, the quality of the search results will be substantially worse. Try to only search over a large number of files if it is really necessary. Unless you know exactly what directory you need to search for, please do not set the targetDirectory parameter.\\nParameters:\\n```json\\n{\\n                \\\"type\\\": \\\"object\\\",\\n                \\\"properties\\\": {\\n                    \\\"query\\\": {\\n                        \\\"type\\\": \\\"string\\\",\\n                        \\\"description\\\": \\\"Search query\\\"\\n                    },\\n                    \\\"targetDirectory\\\": {\\n                        \\\"type\\\": \\\"string\\\",\\n                        \\\"description\\\": \\\"Relative directory path from workspace to search for. this value must be a relative path based on the current project workspace, not a file path.\\\"\\n                    }\\n                },\\n                \\\"required\\\": [\\n                    \\\"query\\\"\\n                ]\\n            }\\n```\\nUsage:\\n<codebase_semantic_search>\\n<query>code keywords here</query>\\n</codebase_semantic_search>\\n\\n\\n\\n# 角色2: 通用编程知识专家\\n\\n## 目标\\n在该角色中，你负责直接回答用户的通用编程问题，这些问题通常与用户的代码无关。例如“如何实现一个排序算法？”、“如何使用Python的requests库？”、“什么是MVC”等等。\\n\\n## 工作流程\\n    1. 直接回答用户的问题，不要使用任何工具\\n    2. *除此之外你不做任何事情*\\n\\n## 输出格式\\n - 输出格式\\n ```\\n<answer>\\n答案\\n</answer>\\n```\\n- *通篇只输出<answer>块，不要输出其它内容*\\n\\n## 角色约束\\n - 不能使用任何工具，也不能规划任何工具调用\\n\\n\\n# 规则\\n- 无论选择哪种角色，不要在<step>或<answer>块之外输出任何额外文字。\\n\\n\\n# system_information\\n- 当前工作目录:```/Users/yueue/workspace/monitor/agentsdk/java```\\n- 当前工程文件部分结构快照，注意这些信息很可能已经过时，且只摘取了前400个:\\n```\\ndependency-reduced-pom.xml\\njava-sdk (1).iml\\npom.xml\\nsrc/.DS_Store\\nsrc/main/.DS_Store\\ntarget/protoc-plugins/protoc-3.21.12-osx-aarch_64.exe\\nsrc/main/proto/curve_data.proto\\nsrc/main/proto/string_data.proto\\ntarget/classes/com/tencent/teg/monitor/.DS_Store\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/any.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/api.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/descriptor.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/duration.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/empty.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/field_mask.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/source_context.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/struct.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/timestamp.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/type.proto\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/wrappers.proto\\nsrc/main/java/com/tencent/teg/monitor/.DS_Store\\ntarget/classes/com/tencent/teg/monitor/sdk/CurveReporter.class\\ntarget/classes/com/tencent/teg/monitor/sdk/TegCurveMonitor.class\\ntarget/classes/com/tencent/teg/monitor/sdk/TegMonitor.class\\ntarget/classes/com/tencent/teg/monitor/sdk/TegStringMonitor.class\\ntarget/classes/com/tencent/teg/monitor/sdk/package-info.class\\ntarget/classes/com/tencent/teg/monitor/pojo/AgentResponse.class\\ntarget/classes/com/tencent/teg/monitor/pojo/AggregatedMetricPkg.class\\ntarget/classes/com/tencent/teg/monitor/pojo/BucketsValue$Bucket.class\\ntarget/classes/com/tencent/teg/monitor/pojo/BucketsValue.class\\ntarget/classes/com/tencent/teg/monitor/pojo/CurveCalMethod.class\\ntarget/classes/com/tencent/teg/monitor/pojo/CurveDataPoint.class\\ntarget/classes/com/tencent/teg/monitor/pojo/GroupOfMetrics.class\\ntarget/classes/com/tencent/teg/monitor/pojo/MonitorConfigData.class\\ntarget/classes/com/tencent/teg/monitor/pojo/SDKCurveReport.class\\ntarget/classes/com/tencent/teg/monitor/pojo/SDKStringReport.class\\ntarget/classes/com/tencent/teg/monitor/pojo/StatData.class\\ntarget/classes/com/tencent/teg/monitor/pojo/TDValue.class\\ntarget/classes/com/tencent/teg/monitor/common/RetCode.class\\ntarget/classes/com/tencent/teg/monitor/conf/MonitorConfig.class\\ntarget/classes/com/tencent/teg/monitor/task/MetricAggregator.class\\ntarget/classes/com/tencent/teg/monitor/task/SendTask.class\\ntarget/classes/com/tencent/teg/monitor/task/StatTask.class\\ntarget/classes/com/tencent/teg/monitor/task/StringSendTask.class\\ntarget/classes/com/tencent/teg/monitor/task/StringStatTask.class\\ntarget/classes/com/tencent/teg/monitor/task/package-info.class\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/compiler/plugin.proto\\ntarget/classes/com/tencent/teg/monitor/utils/CommonUtil.class\\ntarget/classes/com/tencent/teg/monitor/utils/Main.class\\ntarget/classes/com/tencent/teg/monitor/utils/Pair.class\\nsrc/main/java/com/tencent/teg/monitor/conf/MonitorConfig.java\\nsrc/main/java/com/tencent/teg/monitor/common/RetCode.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/AgentResponse.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/AggregatedMetricPkg.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/BucketsValue.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/CurveCalMethod.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/CurveDataPoint.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/GroupOfMetrics.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/MonitorConfigData.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/SDKCurveReport.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/SDKStringReport.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/StatData.java\\nsrc/main/java/com/tencent/teg/monitor/pojo/TDValue.java\\nsrc/main/java/com/tencent/teg/monitor/sdk/CurveReporter.java\\nsrc/main/java/com/tencent/teg/monitor/sdk/TegCurveMonitor.java\\nsrc/main/java/com/tencent/teg/monitor/sdk/TegMonitor.java\\nsrc/main/java/com/tencent/teg/monitor/sdk/TegStringMonitor.java\\nsrc/main/java/com/tencent/teg/monitor/sdk/package-info.java\\nsrc/main/java/com/tencent/teg/monitor/task/MetricAggregator.java\\nsrc/main/java/com/tencent/teg/monitor/task/SendTask.java\\nsrc/main/java/com/tencent/teg/monitor/task/StatTask.java\\nsrc/main/java/com/tencent/teg/monitor/task/StringSendTask.java\\nsrc/main/java/com/tencent/teg/monitor/task/StringStatTask.java\\nsrc/main/java/com/tencent/teg/monitor/task/package-info.java\\nsrc/main/java/com/tencent/teg/monitor/utils/CommonUtil.java\\nsrc/main/java/com/tencent/teg/monitor/utils/Main.java\\nsrc/main/java/com/tencent/teg/monitor/utils/Pair.java\\ntarget/classes/com/tencent/teg/monitor/task/sender/AgentSocketSender.class\\ntarget/classes/com/tencent/teg/monitor/task/sender/PrintSender.class\\ntarget/classes/com/tencent/teg/monitor/task/sender/Sender.class\\ntarget/test-classes/com/tencent/teg/monitor/sdk/CurveV1APITest.class\\ntarget/test-classes/com/tencent/teg/monitor/sdk/CurveV2APITest.class\\ntarget/test-classes/com/tencent/teg/monitor/sdk/SocketServer.class\\ntarget/test-classes/com/tencent/teg/monitor/sdk/StringAPITest.class\\ntarget/test-classes/com/tencent/teg/monitor/task/MetricAggregatorTest.class\\nsrc/test/java/com/tencent/teg/monitor/sdk/CurveV1APITest.java\\nsrc/test/java/com/tencent/teg/monitor/sdk/CurveV2APITest.java\\nsrc/test/java/com/tencent/teg/monitor/sdk/SocketServer.java\\nsrc/test/java/com/tencent/teg/monitor/sdk/StringAPITest.java\\nsrc/test/java/com/tencent/teg/monitor/task/MetricAggregatorTest.java\\nsrc/main/java/com/tencent/teg/monitor/task/sender/AgentSocketSender.java\\nsrc/main/java/com/tencent/teg/monitor/task/sender/PrintSender.java\\nsrc/main/java/com/tencent/teg/monitor/task/sender/Sender.java\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket/DomainSocketFactory.class\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket/SocketFactory.class\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket/TcpSocketFactory.class\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket/DomainSocketFactory.java\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket/SocketFactory.java\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket/TcpSocketFactory.java\\n```\\n- 当前项目内目录结构快照为：（注意这些信息可能不完整，因为只摘取了前200个）\\n```\\nsrc\\ntarget\\nsrc/main\\nsrc/test\\ntarget/classes\\ntarget/generated-sources\\ntarget/protoc-dependencies\\ntarget/protoc-plugins\\ntarget/test-classes\\nsrc/test/java\\nsrc/test/resources\\nsrc/main/java\\nsrc/main/proto\\ntarget/classes/com\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff\\ntarget/generated-sources/protobuf\\nsrc/test/java/com\\ntarget/test-classes/com\\nsrc/main/java/com\\ntarget/classes/com/tencent\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google\\ntarget/generated-sources/protobuf/grpc-java\\ntarget/generated-sources/protobuf/java\\nsrc/test/java/com/tencent\\nsrc/main/java/com/tencent\\ntarget/classes/com/tencent/teg\\ntarget/test-classes/com/tencent\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf\\nsrc/test/java/com/tencent/teg\\nsrc/main/java/com/tencent/teg\\ntarget/classes/com/tencent/teg/monitor\\ntarget/test-classes/com/tencent/teg\\nsrc/main/java/com/tencent/teg/monitor\\ntarget/classes/com/tencent/teg/monitor/common\\ntarget/classes/com/tencent/teg/monitor/conf\\ntarget/classes/com/tencent/teg/monitor/pojo\\ntarget/classes/com/tencent/teg/monitor/sdk\\ntarget/classes/com/tencent/teg/monitor/task\\ntarget/classes/com/tencent/teg/monitor/utils\\ntarget/test-classes/com/tencent/teg/monitor\\nsrc/test/java/com/tencent/teg/monitor\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/compiler\\nsrc/main/java/com/tencent/teg/monitor/common\\nsrc/main/java/com/tencent/teg/monitor/conf\\nsrc/main/java/com/tencent/teg/monitor/pojo\\nsrc/main/java/com/tencent/teg/monitor/sdk\\nsrc/main/java/com/tencent/teg/monitor/task\\nsrc/main/java/com/tencent/teg/monitor/utils\\ntarget/classes/com/tencent/teg/monitor/task/sender\\ntarget/test-classes/com/tencent/teg/monitor/sdk\\ntarget/test-classes/com/tencent/teg/monitor/task\\nsrc/test/java/com/tencent/teg/monitor/sdk\\nsrc/test/java/com/tencent/teg/monitor/task\\nsrc/main/java/com/tencent/teg/monitor/task/sender\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket\\n```\\n\",\"model_caller_payload\":\"{\\\"messages\\\": [{\\\"role\\\": \\\"system\\\", \\\"content\\\": \\\"你是一个编程助手，你身兼两种角色，你需要根据用户的问题选择一个合适的角色来解答用户的问题。\\\\n*你全程只能选择一种角色，禁止同时选择两种角色，也禁止中途切换角色，哪怕不回答用户问题*。\\\\n在回答问题前，先告知你选择的是哪个角色，并输出在<role></role>中\\\\n\\\\n\\\\n# 角色1: 信息检索工具专家\\\\n\\\\n## 目标\\\\n在该角色中，你负责分析用户问题需要哪些支持信息，帮助用户制定合适的工具调用方案。\\\\n\\\\n## 工作流程\\\\n    1. 解析问题所需的信息类型\\\\n    2. 根据工具特性选择最优检索路径\\\\n    3. 生成符合规范的工具调用指令\\\\n    4. 除此之外不做任何事情，*绝对禁止擅自回答用户问题*\\\\n\\\\n## 输出格式\\\\n- 每个步骤在单独的step标签中，每个步骤的格式为：\\\\n```\\\\n<step>\\\\n<tinking></thinking>\\\\n<tool_use>\\\\n<read_file>parameters of tool</read_file>\\\\n</tool_use>\\\\n</step>\\\\n```\\\\n- 每个step中只允许有一个工具调用\\\\n- <thinking>中必须且仅包括合理的逻辑链: \\\\n    1. 用户问题需要什么信息？\\\\n    2. 可能在什么地方？\\\\n    3. 首选什么工具？\\\\n- 严禁只有<thinking>块没有<tool_use>块的输出\\\\n- *通篇只输出<step>块，不要输出任何额外内容*\\\\n\\\\n## 角色约束\\\\n- 告知用户如何使用工具时，应当始终严格按照工具调用模式进行，并确保提供所有必要的参数。\\\\n- 请优先使用view_code_item工具查找函数，结构体或者类的定义，其次是codebase_grep_search工具，最后是read_file工具。\\\\n- 当需要进行语义搜索时，优先使用codebase_semantic_search工具，不要直接调用codebase_grep_search工具。\\\\n- 在使用codebase_grep_search工具的时候,不要给需要搜索的关键字加其他关键字,直接去搜索用户指定的关键字。\\\\n- 当需要查找文件名或者文件位置时，优先使用search_files工具查找文件位置。\\\\n- 后续system_information章节中包含了部分用户项目结构信息，你来决定是否需要使用list_dir工具获取更多目录结构\\\\n- *read_file工具的endLineOneIndexedInclusive参数减去startLineOneIndexed 参数必须大于200且小于2500，例如startLineOneIndexed = 100，endLineOneIndexedInclusive=150是不合法的*\\\\n- 在使用read_file工具的时候,如果你不确定需要读多少内容，直接读所有内容，如果需要全部文件内容，请每次按照允许读取的最大行数读取\\\\n- *不要擅自猜测检索工具的执行结果是未找到，你只负责提供你认为必要的检索工具调用方案即可*\\\\n- *不要基于假设的工具返回信息来进行规划*\\\\n- *方案应该尽可能简短*\\\\n- *不能使用可用工具列表之外的工具，否则程序可能出错*\\\\n\\\\n## 可用的工具列表\\\\n\\\\n### read_file\\\\nDescription: 请求读取指定路径下文件的内容。当你需要检查一个你不知道内容的现有文件的内容时，例如分析代码、查看文本文件或从配置文件中提取信息，请使用此功能。自动从PDF和DOCX文件中提取原始文本。可能不适用于其他类型的二进制文件，因为它会将原始内容作为字符串返回。\\\\nParameters:\\\\n```json\\\\n{\\\\n            \\\\\\\"type\\\\\\\": \\\\\\\"object\\\\\\\",\\\\n            \\\\\\\"properties\\\\\\\": {\\\\n                \\\\\\\"endLineOneIndexedInclusive\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"integer\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"The one-indexed line number to end reading at (inclusive). file is 1-indexed start\\\\\\\"\\\\n                },\\\\n                \\\\\\\"relativeWorkspacePath\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"The path of the file to read, relative to the workspace root.\\\\\\\"\\\\n                },\\\\n                \\\\\\\"absoluteWorkspacePath\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"The path of the file to read, absolute path based on working directory.\\\\\\\"\\\\n                },\\\\n                \\\\\\\"shouldReadEntireFile\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"boolean\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"Whether to read the entire file. Defaults to false.\\\\\\\"\\\\n                },\\\\n                \\\\\\\"startLineOneIndexed\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"integer\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"The one-indexed line number to start reading from (inclusive). file is 1-indexed start\\\\\\\"\\\\n                }\\\\n            },\\\\n            \\\\\\\"required\\\\\\\": [\\\\n                \\\\\\\"relativeWorkspacePath\\\\\\\",\\\\n                \\\\\\\"shouldReadEntireFile\\\\\\\",\\\\n                \\\\\\\"startLineOneIndexed\\\\\\\",\\\\n                \\\\\\\"endLineOneIndexedInclusive\\\\\\\",\\\\n                \\\\\\\"absoluteWorkspacePath\\\\\\\"\\\\n            ]\\\\n}\\\\n```\\\\nUsage:\\\\n<read_file>\\\\n<relativeWorkspacePath>File path here</relativeWorkspacePath>\\\\n<shouldReadEntireFile>true or false</shouldReadEntireFile>\\\\n<startLineOneIndexed>start line number</startLineOneIndexed>\\\\n<endLineOneIndexedInclusive>end line number</endLineOneIndexedInclusive>\\\\n<absoluteWorkspacePath>File path here</absoluteWorkspacePath>\\\\n</read_file>\\\\n\\\\n### search_files\\\\nDescription: 请求在指定目录中的文件中执行正则表达式搜索，提供包含丰富上下文的结果。此工具在多个文件中搜索模式或特定内容，显示每个匹配项及其周围的上下文。\\\\nParameters:\\\\n```json\\\\n{\\\\n            \\\\\\\"type\\\\\\\": \\\\\\\"object\\\\\\\",\\\\n            \\\\\\\"properties\\\\\\\": {\\\\n                \\\\\\\"explanation\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"One sentence explanation as to why this tool is being used, and how it contributes to the goal.\\\\\\\"\\\\n                },\\\\n                \\\\\\\"query\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"filename keyword or wildcard pattern (e.g., 'abc_*.cpp' or '*_test.go')\\\\\\\"\\\\n                },\\\\n                 \\\\\\\"readWhenFound\\\\\\\": {\\\\n                     \\\\\\\"type\\\\\\\": \\\\\\\"boolean\\\\\\\",\\\\n                     \\\\\\\"description\\\\\\\": \\\\\\\"Specifies whether the contents of the file should be read immediately after it is found. This parameter should be true if the purpose of finding a file is to obtain the contents of the file\\\\\\\"\\\\n                }\\\\n            },\\\\n            \\\\\\\"required\\\\\\\": [\\\\n                \\\\\\\"query\\\\\\\",\\\\\\\"readWhenFound\\\\\\\"\\\\n            ]\\\\n        }\\\\n```\\\\nUsage:\\\\n<search_files>\\\\n<query>Your keyword here</query>\\\\n<readWhenFound>true or false</readWhenFound>\\\\n</search_files>\\\\n\\\\n### list_dir\\\\nDescription: 请求列出指定目录中的文件和目录。如果递归（recursive）为true，它将递归地列出所有文件和目录。如果递归为false或未提供，它将仅列出顶层内容。不要使用此工具来确认你可能创建的文件是否存在，因为用户会告知你文件是否成功创建。\\\\nParameters:\\\\n```json\\\\n{\\\\n            \\\\\\\"type\\\\\\\": \\\\\\\"object\\\\\\\",\\\\n            \\\\\\\"properties\\\\\\\": {\\\\n                \\\\\\\"path\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"Path to list contents of, should be absolute path to a directory\\\\\\\"\\\\n                },\\\\n                \\\\\\\"recursive\\\\\\\": {\\\\n                    \\\\\\\"type\\\\\\\": \\\\\\\"boolean\\\\\\\",\\\\n                    \\\\\\\"description\\\\\\\": \\\\\\\"Whether to list files recursively\\\\\\\"\\\\n                }\\\\n            },\\\\n            \\\\\\\"required\\\\\\\": [\\\\n                \\\\\\\"path\\\\\\\",\\\\n                \\\\\\\"recursive\\\\\\\"\\\\n            ]\\\\n}\\\\n```\\\\nUsage:\\\\n<list_dir>\\\\n<path>Directory path here</path>\\\\n<recursive>true or false</recursive>\\\\n</list_dir>\\\\n\\\\n### codebase_grep_search\\\\nDescription: Fast text-based regex search that finds exact pattern matches within files or directories,utilizing the ripgrep command for efficient searching.\\\\\\\\nResults will be formatted in the style of ripgrep and can be configured to include line numbers and content.\\\\\\\\nTo avoid overwhelming output, the results are capped at 50 matches.\\\\\\\\nUse the include or exclude patterns to filter the search scope by file type or specific paths.\\\\\\\\nThis is best for finding exact text matches or regex patterns.\\\\\\\\nMore precise than semantic search for finding specific strings or patterns.\\\\\\\\nThis is preferred over semantic search when we know the exact symbol/function name/etc. to search in some set of directories/file types\\\\nParameters:\\\\n```json\\\\n{\\\\n                \\\\\\\"type\\\\\\\": \\\\\\\"object\\\\\\\",\\\\n                \\\\\\\"properties\\\\\\\": {\\\\n                    \\\\\\\"query\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"The search term or keyword to look for within files.\\\\\\\"\\\\n                    },\\\\n                    \\\\\\\"searchDirectory\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"The directory to search, this value must be a relative path based on the current project workspace, not a file path.\\\\\\\"\\\\n                    },\\\\n                    \\\\\\\"useRegex\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"boolean\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"Indicate whether to search keywords using regular expression pattern or exact string matching\\\\\\\"\\\\n                    },\\\\n                    \\\\\\\"readWhenFound\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"boolean\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"Specifies whether the contents of the file should be read immediately after it is found. This parameter should be true if the purpose of finding a file is to obtain the contents of the file\\\\\\\"\\\\n                    }\\\\n                },\\\\n                \\\\\\\"required\\\\\\\": [\\\\\\\"searchDirectory\\\\\\\", \\\\\\\"query\\\\\\\", \\\\\\\"useRegex\\\\\\\",\\\\\\\"readWhenFound\\\\\\\"]\\\\n            }\\\\n```\\\\nUsage:\\\\n<codebase_grep_search>\\\\n<searchDirectory>search directory path here</searchDirectory>\\\\n<query>code keywords here</query>\\\\n<useRegex>true of false</useRegex>\\\\n<readWhenFound>true of false</readWhenFound>\\\\n</codebase_grep_search>\\\\n\\\\n\\\\n### view_code_item\\\\nDescription: Query the definition of symbols such as functions, classes, or variables in current project. you must provide a clear symbol name. Fuzzy searching and multi-level symbols like Foo.bar are not supported. Unless you know exactly what file you need to search for, please do not set the file parameter. If the symbol is not found, the tool will return an empty result instead.\\\\nParameters:\\\\n```json\\\\n{\\\\n                \\\\\\\"type\\\\\\\": \\\\\\\"object\\\\\\\",\\\\n                \\\\\\\"properties\\\\\\\": {\\\\n                    \\\\\\\"file\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"Relative file path from workspace to search for, e.g relative_path/to/file\\\\\\\"\\\\n                    },\\\\n                    \\\\\\\"symbolName\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"A specific and precise symbol name.\\\\\\\"\\\\n                    }\\\\n                },\\\\n                \\\\\\\"required\\\\\\\": [\\\\\\\"symbolName\\\\\\\"]\\\\n            }\\\\n```\\\\nUsage:\\\\n<view_code_item>\\\\n<symbolName>code keywords here</symbolName>\\\\n</view_code_item>\\\\n\\\\n### codebase_semantic_search\\\\nDescription: Find snippets of code from the codebase most relevant to the search query. This performs best when the search query is more precise and relating to the function or purpose of code. Results will be poor if asking a very broad question, such as asking about the general 'framework' or 'implementation' of a large component or system. Will only show the full code contents of the top items, and they may also be truncated. For other items it will only show the docstring and signature. Use view_code_item with the same path and node name to view the full code contents for any item. Note that if you try to search over more than 500 files, the quality of the search results will be substantially worse. Try to only search over a large number of files if it is really necessary. Unless you know exactly what directory you need to search for, please do not set the targetDirectory parameter.\\\\nParameters:\\\\n```json\\\\n{\\\\n                \\\\\\\"type\\\\\\\": \\\\\\\"object\\\\\\\",\\\\n                \\\\\\\"properties\\\\\\\": {\\\\n                    \\\\\\\"query\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"Search query\\\\\\\"\\\\n                    },\\\\n                    \\\\\\\"targetDirectory\\\\\\\": {\\\\n                        \\\\\\\"type\\\\\\\": \\\\\\\"string\\\\\\\",\\\\n                        \\\\\\\"description\\\\\\\": \\\\\\\"Relative directory path from workspace to search for. this value must be a relative path based on the current project workspace, not a file path.\\\\\\\"\\\\n                    }\\\\n                },\\\\n                \\\\\\\"required\\\\\\\": [\\\\n                    \\\\\\\"query\\\\\\\"\\\\n                ]\\\\n            }\\\\n```\\\\nUsage:\\\\n<codebase_semantic_search>\\\\n<query>code keywords here</query>\\\\n</codebase_semantic_search>\\\\n\\\\n\\\\n\\\\n# 角色2: 通用编程知识专家\\\\n\\\\n## 目标\\\\n在该角色中，你负责直接回答用户的通用编程问题，这些问题通常与用户的代码无关。例如“如何实现一个排序算法？”、“如何使用Python的requests库？”、“什么是MVC”等等。\\\\n\\\\n## 工作流程\\\\n    1. 直接回答用户的问题，不要使用任何工具\\\\n    2. *除此之外你不做任何事情*\\\\n\\\\n## 输出格式\\\\n - 输出格式\\\\n ```\\\\n<answer>\\\\n答案\\\\n</answer>\\\\n```\\\\n- *通篇只输出<answer>块，不要输出其它内容*\\\\n\\\\n## 角色约束\\\\n - 不能使用任何工具，也不能规划任何工具调用\\\\n\\\\n\\\\n# 规则\\\\n- 无论选择哪种角色，不要在<step>或<answer>块之外输出任何额外文字。\\\\n\\\\n\\\\n# system_information\\\\n- 当前工作目录:```/Users/yueue/workspace/monitor/agentsdk/java```\\\\n- 当前工程文件部分结构快照，注意这些信息很可能已经过时，且只摘取了前400个:\\\\n```\\\\ndependency-reduced-pom.xml\\\\njava-sdk (1).iml\\\\npom.xml\\\\nsrc/.DS_Store\\\\nsrc/main/.DS_Store\\\\ntarget/protoc-plugins/protoc-3.21.12-osx-aarch_64.exe\\\\nsrc/main/proto/curve_data.proto\\\\nsrc/main/proto/string_data.proto\\\\ntarget/classes/com/tencent/teg/monitor/.DS_Store\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/any.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/api.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/descriptor.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/duration.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/empty.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/field_mask.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/source_context.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/struct.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/timestamp.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/type.proto\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/wrappers.proto\\\\nsrc/main/java/com/tencent/teg/monitor/.DS_Store\\\\ntarget/classes/com/tencent/teg/monitor/sdk/CurveReporter.class\\\\ntarget/classes/com/tencent/teg/monitor/sdk/TegCurveMonitor.class\\\\ntarget/classes/com/tencent/teg/monitor/sdk/TegMonitor.class\\\\ntarget/classes/com/tencent/teg/monitor/sdk/TegStringMonitor.class\\\\ntarget/classes/com/tencent/teg/monitor/sdk/package-info.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/AgentResponse.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/AggregatedMetricPkg.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/BucketsValue$Bucket.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/BucketsValue.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/CurveCalMethod.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/CurveDataPoint.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/GroupOfMetrics.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/MonitorConfigData.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/SDKCurveReport.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/SDKStringReport.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/StatData.class\\\\ntarget/classes/com/tencent/teg/monitor/pojo/TDValue.class\\\\ntarget/classes/com/tencent/teg/monitor/common/RetCode.class\\\\ntarget/classes/com/tencent/teg/monitor/conf/MonitorConfig.class\\\\ntarget/classes/com/tencent/teg/monitor/task/MetricAggregator.class\\\\ntarget/classes/com/tencent/teg/monitor/task/SendTask.class\\\\ntarget/classes/com/tencent/teg/monitor/task/StatTask.class\\\\ntarget/classes/com/tencent/teg/monitor/task/StringSendTask.class\\\\ntarget/classes/com/tencent/teg/monitor/task/StringStatTask.class\\\\ntarget/classes/com/tencent/teg/monitor/task/package-info.class\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/compiler/plugin.proto\\\\ntarget/classes/com/tencent/teg/monitor/utils/CommonUtil.class\\\\ntarget/classes/com/tencent/teg/monitor/utils/Main.class\\\\ntarget/classes/com/tencent/teg/monitor/utils/Pair.class\\\\nsrc/main/java/com/tencent/teg/monitor/conf/MonitorConfig.java\\\\nsrc/main/java/com/tencent/teg/monitor/common/RetCode.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/AgentResponse.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/AggregatedMetricPkg.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/BucketsValue.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/CurveCalMethod.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/CurveDataPoint.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/GroupOfMetrics.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/MonitorConfigData.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/SDKCurveReport.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/SDKStringReport.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/StatData.java\\\\nsrc/main/java/com/tencent/teg/monitor/pojo/TDValue.java\\\\nsrc/main/java/com/tencent/teg/monitor/sdk/CurveReporter.java\\\\nsrc/main/java/com/tencent/teg/monitor/sdk/TegCurveMonitor.java\\\\nsrc/main/java/com/tencent/teg/monitor/sdk/TegMonitor.java\\\\nsrc/main/java/com/tencent/teg/monitor/sdk/TegStringMonitor.java\\\\nsrc/main/java/com/tencent/teg/monitor/sdk/package-info.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/MetricAggregator.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/SendTask.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/StatTask.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/StringSendTask.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/StringStatTask.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/package-info.java\\\\nsrc/main/java/com/tencent/teg/monitor/utils/CommonUtil.java\\\\nsrc/main/java/com/tencent/teg/monitor/utils/Main.java\\\\nsrc/main/java/com/tencent/teg/monitor/utils/Pair.java\\\\ntarget/classes/com/tencent/teg/monitor/task/sender/AgentSocketSender.class\\\\ntarget/classes/com/tencent/teg/monitor/task/sender/PrintSender.class\\\\ntarget/classes/com/tencent/teg/monitor/task/sender/Sender.class\\\\ntarget/test-classes/com/tencent/teg/monitor/sdk/CurveV1APITest.class\\\\ntarget/test-classes/com/tencent/teg/monitor/sdk/CurveV2APITest.class\\\\ntarget/test-classes/com/tencent/teg/monitor/sdk/SocketServer.class\\\\ntarget/test-classes/com/tencent/teg/monitor/sdk/StringAPITest.class\\\\ntarget/test-classes/com/tencent/teg/monitor/task/MetricAggregatorTest.class\\\\nsrc/test/java/com/tencent/teg/monitor/sdk/CurveV1APITest.java\\\\nsrc/test/java/com/tencent/teg/monitor/sdk/CurveV2APITest.java\\\\nsrc/test/java/com/tencent/teg/monitor/sdk/SocketServer.java\\\\nsrc/test/java/com/tencent/teg/monitor/sdk/StringAPITest.java\\\\nsrc/test/java/com/tencent/teg/monitor/task/MetricAggregatorTest.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender/AgentSocketSender.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender/PrintSender.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender/Sender.java\\\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket/DomainSocketFactory.class\\\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket/SocketFactory.class\\\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket/TcpSocketFactory.class\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket/DomainSocketFactory.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket/SocketFactory.java\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket/TcpSocketFactory.java\\\\n```\\\\n- 当前项目内目录结构快照为：（注意这些信息可能不完整，因为只摘取了前200个）\\\\n```\\\\nsrc\\\\ntarget\\\\nsrc/main\\\\nsrc/test\\\\ntarget/classes\\\\ntarget/generated-sources\\\\ntarget/protoc-dependencies\\\\ntarget/protoc-plugins\\\\ntarget/test-classes\\\\nsrc/test/java\\\\nsrc/test/resources\\\\nsrc/main/java\\\\nsrc/main/proto\\\\ntarget/classes/com\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff\\\\ntarget/generated-sources/protobuf\\\\nsrc/test/java/com\\\\ntarget/test-classes/com\\\\nsrc/main/java/com\\\\ntarget/classes/com/tencent\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google\\\\ntarget/generated-sources/protobuf/grpc-java\\\\ntarget/generated-sources/protobuf/java\\\\nsrc/test/java/com/tencent\\\\nsrc/main/java/com/tencent\\\\ntarget/classes/com/tencent/teg\\\\ntarget/test-classes/com/tencent\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf\\\\nsrc/test/java/com/tencent/teg\\\\nsrc/main/java/com/tencent/teg\\\\ntarget/classes/com/tencent/teg/monitor\\\\ntarget/test-classes/com/tencent/teg\\\\nsrc/main/java/com/tencent/teg/monitor\\\\ntarget/classes/com/tencent/teg/monitor/common\\\\ntarget/classes/com/tencent/teg/monitor/conf\\\\ntarget/classes/com/tencent/teg/monitor/pojo\\\\ntarget/classes/com/tencent/teg/monitor/sdk\\\\ntarget/classes/com/tencent/teg/monitor/task\\\\ntarget/classes/com/tencent/teg/monitor/utils\\\\ntarget/test-classes/com/tencent/teg/monitor\\\\nsrc/test/java/com/tencent/teg/monitor\\\\ntarget/protoc-dependencies/c0d6fad7422ff51be50547c50790d0ff/google/protobuf/compiler\\\\nsrc/main/java/com/tencent/teg/monitor/common\\\\nsrc/main/java/com/tencent/teg/monitor/conf\\\\nsrc/main/java/com/tencent/teg/monitor/pojo\\\\nsrc/main/java/com/tencent/teg/monitor/sdk\\\\nsrc/main/java/com/tencent/teg/monitor/task\\\\nsrc/main/java/com/tencent/teg/monitor/utils\\\\ntarget/classes/com/tencent/teg/monitor/task/sender\\\\ntarget/test-classes/com/tencent/teg/monitor/sdk\\\\ntarget/test-classes/com/tencent/teg/monitor/task\\\\nsrc/test/java/com/tencent/teg/monitor/sdk\\\\nsrc/test/java/com/tencent/teg/monitor/task\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender\\\\ntarget/classes/com/tencent/teg/monitor/task/sender/socket\\\\nsrc/main/java/com/tencent/teg/monitor/task/sender/socket\\\\n```\\\\n\\\"}, {\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"java 有多少个版本\\\"}, {\\\"role\\\": \\\"assistant\\\", \\\"content\\\": \\\"Java从诞生至今有多个主要版本，以下是重要版本及其发布时间：\\\\n\\\\n1. JDK 1.0 (1996)\\\\n2. JDK 1.1 (1997)\\\\n3. J2SE 1.2 (1998)\\\\n4. J2SE 1.3 (2000)\\\\n5. J2SE 1.4 (2002)\\\\n6. J2SE 5.0 (2004)\\\\n7. Java SE 6 (2006)\\\\n8. Java SE 7 (2011)\\\\n9. Java SE 8 (LTS) (2014)\\\\n10. Java SE 9 (2017)\\\\n11. Java SE 10 (2018)\\\\n12. Java SE 11 (LTS) (2018)\\\\n13. Java SE 12 (2019)\\\\n14. Java SE 13 (2019)\\\\n15. Java SE 14 (2020)\\\\n16. Java SE 15 (2020)\\\\n17. Java SE 16 (2021)\\\\n18. Java SE 17 (LTS) (2021)\\\\n19. Java SE 18 (2022)\\\\n20. Java SE 19 (2022)\\\\n21. Java SE 20 (2023)\\\\n22. Java SE 21 (LTS) (2023)\\\\n\\\\n其中LTS（Long Term Support）版本是长期支持版本，包括Java 8、Java 11、Java 17和Java 21。这些版本会获得更长时间的更新和支持。目前使用最广泛的是Java 8和Java 11。\\\"}, {\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"解释一下我的项目\\\"}, {\\\"role\\\": \\\"assistant\\\", \\\"content\\\": \\\"你的项目是一个监控SDK，主要用于收集和上报监控数据。以下是项目的主要组成部分和功能：\\\\n\\\\n1. **核心类**：\\\\n   - `TegMonitor.java`：监控SDK的核心类，负责初始化和管理监控任务。它提供了初始化方法（`init`）和数据上报方法（`addCurveData` 和 `addStringData`）。\\\\n   - `CurveReporter.java`：负责曲线数据的收集和上报，通常用于监控指标的时间序列数据。\\\\n\\\\n2. **数据发送**：\\\\n   - `AgentSocketSender.java`：处理监控数据的发送，通过Socket与监控代理进行通信。它负责将数据打包并发送到监控代理，并处理代理的响应。\\\\n\\\\n3. **数据聚合**：\\\\n   - `MetricAggregator.java`：负责将多个监控数据点进行聚合计算，支持多种计算方式（如求和、平均值、最大值、最小值等）。\\\\n\\\\n4. **协议缓冲区定义**：\\\\n   - `curve_data.proto`：定义了监控数据的协议缓冲区格式，用于序列化和反序列化监控数据。\\\\n\\\\n5. **构建配置**：\\\\n   - `pom.xml`：Maven构建配置文件，用于管理项目依赖和构建过程。项目依赖包括`junixsocket-core`（用于Unix域套接字）、`protobuf-java`（用于协议缓冲区）、`slf4j`（用于日志记录）等。\\\\n\\\\n### 项目功能\\\\n- **数据收集**：通过`TegMonitor`和`CurveReporter`收集监控数据。\\\\n- **数据聚合**：通过`MetricAggregator`对收集到的数据进行聚合计算。\\\\n- **数据发送**：通过`AgentSocketSender`将聚合后的数据发送到监控代理。\\\\n- **协议缓冲区**：使用`curve_data.proto`定义的数据格式进行数据序列化和反序列化。\\\\n\\\\n### 项目结构\\\\n- `src/main/java/com/tencent/teg/monitor/sdk/`：包含监控SDK的核心类。\\\\n- `src/main/java/com/tencent/teg/monitor/task/`：包含任务处理相关的类，如数据聚合和发送。\\\\n- `src/main/proto/`：包含协议缓冲区定义文件。\\\\n\\\\n### 依赖管理\\\\n项目使用Maven进行依赖管理，主要依赖包括：\\\\n- `junixsocket-core`：用于Unix域套接字通信。\\\\n- `protobuf-java`：用于协议缓冲区。\\\\n- `slf4j`：用于日志记录。\\\\n\\\\n### 总结\\\\n你的项目是一个功能完善的监控SDK，能够收集、聚合和上报监控数据。它通过协议缓冲区定义数据格式，并通过Socket与监控代理进行通信。项目结构清晰，依赖管理规范，适合用于大规模监控系统的数据收集和上报。\\\"}, {\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"我的项目中有心跳相关的代码吗\\\"}, {\\\"role\\\": \\\"assistant\\\", \\\"content\\\": \\\"在你的项目中，确实存在与心跳相关的代码。具体来说，心跳机制在 `CommonUtil.java` 文件中有所体现，特别是在 `byteMergerForTcp` 方法中。以下是相关代码片段：\\\\n\\\\n```\\\\n此处代码已省略\\\\n```\\\\n\\\\n在这段代码中，`packType` 用于标识数据包的类型，其中 `2` 表示 JSON 协议的心跳包，`3` 表示 PB（Protocol Buffers）协议的心跳包。这表明你的项目在 TCP 协议下支持心跳机制，用于保持连接的活跃状态。\\\\n\\\\n如果你需要进一步了解或修改心跳机制的具体实现，可以查看 `CommonUtil.java` 文件中的相关代码。\\\"}, {\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"我的mac电脑vpnagentd进程cpu 99%\\\"}, {\\\"role\\\": \\\"assistant\\\", \\\"content\\\": \\\"当Mac电脑上的vpnagentd进程CPU使用率达到99%时，这通常表示VPN客户端出现了问题。以下是一些解决方案：\\\\n\\\\n1. 立即处理方案：\\\\n   - 在活动监视器中找到vpnagentd进程并强制退出\\\\n   - 或者使用终端命令：`sudo killall vpnagentd`\\\\n\\\\n2. 如果问题仍然存在：\\\\n   - 完全退出VPN客户端\\\\n   - 删除VPN相关进程：\\\\n     ```\\\\n此处代码已省略\\\\n     ```\\\\n\\\\n3. 如果上述方法无效：\\\\n   - 卸载并重新安装VPN客户端\\\\n   - 重启电脑\\\\n\\\\n4. 预防措施：\\\\n   - 保持VPN客户端为最新版本\\\\n   - 定期检查系统更新\\\\n   - 监控VPN连接状态\\\\n\\\\n这个问题通常与VPN客户端的bug或配置问题有关，重启进程或重装客户端通常能解决问题。\\\"}, {\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"这个进程是干什么的\\\"}, {\\\"role\\\": \\\"assistant\\\", \\\"content\\\": \\\"vpnagentd是Cisco AnyConnect VPN客户端的一个守护进程(daemon process)，主要负责以下功能：\\\\n\\\\n1. VPN连接管理：\\\\n   - 维护VPN隧道\\\\n   - 处理认证\\\\n   - 管理网络配置\\\\n\\\\n2. 后台服务：\\\\n   - 作为系统服务持续运行\\\\n   - 响应VPN客户端GUI的请求\\\\n   - 处理网络状态变化\\\\n\\\\n3. 安全功能：\\\\n   - 加密通信\\\\n   - 证书管理\\\\n   - 安全策略执行\\\\n\\\\n这个进程是VPN正常工作所必需的，但如果它占用过高CPU（如99%），就表明进程可能出现了问题，需要重启或者其他修复措施。\\\"}, {\\\"role\\\": \\\"user\\\", \\\"content\\\": \\\"\\\\n* 当前系统时间为：2025-03-18 17:32:36\\\\n以下是用户过往行为信息：（仅供你参考，可能与用户问题有关也可能无关）\\\\n- 当前用户指定的代码文件列表为：\\\\n```json\\\\n[]\\\\n```\\\\n- 当前用户指定的代码片段列表为：\\\\n```json\\\\n[]\\\\n```\\\\n- 当前用户打开的文件为：/Users/yueue/Desktop/planning_prompt_v2\\\\n- 最近用户打开过的文件和时间为：\\\\n```json\\\\n[{\\\\\\\"path\\\\\\\": \\\\\\\"src/main/java/com/tencent/teg/monitor/task/MetricAggregator.java\\\\\\\", \\\\\\\"last_modified_time\\\\\\\": \\\\\\\"2025-02-13 14:34:32\\\\\\\", \\\\\\\"last_open_time\\\\\\\": \\\\\\\"2025-03-18 16:41:59\\\\\\\"}, {\\\\\\\"path\\\\\\\": \\\\\\\"src/main/java/com/tencent/teg/monitor/task/sender/AgentSocketSender.java\\\\\\\", \\\\\\\"last_modified_time\\\\\\\": \\\\\\\"2025-03-13 20:39:05\\\\\\\", \\\\\\\"last_open_time\\\\\\\": \\\\\\\"2025-03-18 16:41:59\\\\\\\"}, {\\\\\\\"path\\\\\\\": \\\\\\\"src/main/proto/curve_data.proto\\\\\\\", \\\\\\\"last_modified_time\\\\\\\": \\\\\\\"2025-03-13 20:39:05\\\\\\\", \\\\\\\"last_open_time\\\\\\\": \\\\\\\"2025-03-18 16:41:59\\\\\\\"}, {\\\\\\\"path\\\\\\\": \\\\\\\"src/main/java/com/tencent/teg/monitor/sdk/TegMonitor.java\\\\\\\", \\\\\\\"last_modified_time\\\\\\\": \\\\\\\"2025-02-27 13:44:48\\\\\\\", \\\\\\\"last_open_time\\\\\\\": \\\\\\\"2025-03-18 16:41:59\\\\\\\"}, {\\\\\\\"path\\\\\\\": \\\\\\\"pom.xml\\\\\\\", \\\\\\\"last_modified_time\\\\\\\": \\\\\\\"2025-03-13 16:56:02\\\\\\\", \\\\\\\"last_open_time\\\\\\\": \\\\\\\"2025-03-18 16:41:59\\\\\\\"}]\\\\n```\\\\n\\\\n*以下是用户问题：*\\\\n```\\\\nvim 下怎么选区\\\\n```\\\\n\\\"}], \\\"temperature\\\": 0, \\\"top_p\\\": 0.5, \\\"model\\\": \\\"bedrock/converse/us.anthropic.claude-3-5-sonnet-20241022-v2:0\\\", \\\"top_k\\\": 1}\",\"model_response\":\"<role>通用编程知识专家</role>\\n\\n<answer>\\n在Vim中有多种方式进行文本选择：\\n\\n1. 可视模式（Visual Mode）选择：\\n- `v` - 字符选择模式，按字符选择\\n- `V` - 行选择模式，按整行选择\\n- `Ctrl+v` - 块选择模式，可以选择矩形区域\\n\\n2. 选择操作：\\n- `h,j,k,l` - 使用方向键移动选区\\n- `w` - 向后选择一个单词\\n- `b` - 向前选择一个单词\\n- `$` - 选择到行尾\\n- `^` - 选择到行首\\n- `gg` - 选择到文件开头\\n- `G` - 选择到文件结尾\\n\\n3. 常用组合：\\n- `vip` - 选择当前段落\\n- `viw` - 选择当前单词\\n- `vi\\\"` - 选择双引号中的内容\\n- `vi{` - 选择花括号中的内容\\n- `vat` - 选择一个HTML标签块\\n\\n4. 取消选择：\\n- `Esc` 或 `Ctrl+[` - 退出可视模式\\n\\n5. 选中后的操作：\\n- `y` - 复制选中内容\\n- `d` - 删除选中内容\\n- `c` - 删除选中内容并进入插入模式\\n- `>` - 向右缩进\\n- `<` - 向左缩进\\n\\n记住：在任何选择模式下，你都可以使用数字来指定重复次数，比如`3v`会选择3个字符。\\n</answer>\",\"model_response_id\":\"chatcmpl-d8976560-2631-46fa-98b8-bbec896e42ed\",\"model_name\":\"bedrock/converse/us.anthropic.claude-3-5-sonnet-20241022-v2:0\",\"model_param\":\"{\\\"temperature\\\": 0, \\\"top_p\\\": 0.5, \\\"model\\\": \\\"bedrock/converse/us.anthropic.claude-3-5-sonnet-20241022-v2:0\\\", \\\"top_k\\\": 1}\",\"model_version\":\"bedrock/converse/us.anthropic.claude-3-5-sonnet-20241022-v2:0\",\"model_response_start_at\":\"2025-03-18 17:32:40\",\"model_response_end_at\":\"2025-03-18 17:32:50\",\"model_usage\":{\"prompt_tokens\":7920,\"completion_tokens\":411,\"total_tokens\":8331},\"request_at\":\"2025-03-18 17:32:36\"}"
	err := producer.PushEvent(ctx, event)
	if err != nil {
		fmt.Printf("Failed to push event: %v\n", err)
		return
	}

	fmt.Println("Successfully pushed event to Kafka")
}
